package com.ld.wms.business;

import com.alibaba.fastjson.JSONObject;
import com.ld.wms.cameraMonitor.NetSDKDemo.ClientDemo;
import com.ld.wms.cameraMonitor.NetSDKDemo.VideoDemo;
import com.ld.wms.common.ResultResponse;
import com.ld.wms.common.vo.GeneratePageListVo;
import com.ld.wms.utils.ExternalDataUtils;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

@Slf4j
@RestController
public class TestCtrl {

    private final ReentrantLock lock = new ReentrantLock();

    @Autowired
    ExternalDataUtils externalDataUtils;

    @GetMapping("getVOCData")
    public Object getVOCData() {
        return externalDataUtils.getVOCData();
    }

    @GetMapping("getTemperatureAndHumidity")
    public Object getTemperatureAndHumidity() {
        return externalDataUtils.getTemperatureAndHumidity();

    }

    @GetMapping("openOrCloseElectronicLock")
    public Object openOrCloseElectronicLock(
            @RequestParam String para
    ) {
        return externalDataUtils.openOrCloseElectronicLock(para);
    }


    @GetMapping("start")
    public Object start() {
       ClientDemo.start("");
        return "success";

    }

    @GetMapping("end")
    public Object end() {
        ClientDemo.end();
        return "success";

    }

   /* @GetMapping("getRealStreamData")
    public Object getRealStreamData() {
        ClientDemo.getRealStreamData();
        return "success";

    }
*/

    @GetMapping("test")
    public Object test(Long id) {
        lock.lock();
        try {
            log.info("线程进来了");
            Thread.sleep(5000L);
            log.info("线程执行结束");
        } catch (Exception e) {

        }finally {
            lock.unlock();
        }
        return "success";
    }

}
